---
redirect_from:
  - /config/databases/ksqldb
---

# ksqlDB

[ksqlDB](https://ksqldb.io) is a purpose-built database for stream processing
applications, ingesting data from [Apache Kafka](https://kafka.apache.org).

<SuccessBox>

ksqlDB support is available in Cube Cloud on
[Enterprise Premier](https://cube.dev/pricing) tier. [Contact
us](https://cube.dev/contact) for details.

</SuccessBox>

See how you can use ksqlDB and Cube Cloud to power real-time analytics in Power BI:

<YouTubeVideo url="https://www.youtube.com/embed/RD_HZ7xE8G0" />

## Prerequisites

- Hostname for the ksqlDB server
- Username and password (or an API key) to connect to ksqlDB server

### Confluent Cloud

If you are using [Confluent Cloud](https://www.confluent.io/confluent-cloud/),
you need to generate an API key and use the API key name as your username and
the API key secret as your password.

You can generate an API key by installing `confluent-cli` and running the
following commands in the command line:

```sh
brew install --cask confluent-cli
confluent login
confluent environment use <YOUR-ENVIRONMENT-ID>
confluent ksql cluster list
confluent api-key create --resource <YOUR-KSQL-CLUSTER-ID>
```

## Setup

### Manual

Add the following to a `.env` file in your Cube project:

```dotenv
CUBEJS_DB_TYPE=ksql
CUBEJS_DB_URL=https://xxxxxx-xxxxx.us-west4.gcp.confluent.cloud:443
CUBEJS_DB_USER=username
CUBEJS_DB_PASS=password
```

## Environment Variables

| Environment Variable | Description                                                                   | Possible Values           | Required |
| -------------------- | ----------------------------------------------------------------------------- | ------------------------- | :------: |
| `CUBEJS_DB_URL`      | The host URL for ksqlDB with port                                             | A valid database host URL |    ✅    |
| `CUBEJS_DB_USER`     | The username used to connect to the ksqlDB. API key for Confluent Cloud.      | A valid port number       |    ✅    |
| `CUBEJS_DB_PASS`     | The password used to connect to the ksqlDB. API secret for Confluent Cloud.   | A valid database name     |    ✅    |
| `CUBEJS_CONCURRENCY` | The number of concurrent connections each queue has to the DB. Default is `1` | A valid number            |    ❌    |

## Pre-Aggregations Support

ksqlDB supports only
[streaming pre-aggregations](/product/caching/using-pre-aggregations#streaming-pre-aggregations).

